function [Ysim,Xsim] = untransformYandX(Ysim,model,Xsim)
ny = size(Ysim,1);
% undo the transformation
for i=1:ny
    if model.transformY(i) == 1
        % log-transformation
    
    elseif model.transformY(i) == 2
        % logistic transformation
        Ysim(i,:) = 1./(1+exp(-Ysim(i,:)));
    elseif model.transformY(i) == 0
        % Level approximation
        
    end
end
if exist('Xsim','var')
    nx          = size(Xsim,1);
    for i=1:nx
        if model.transformX(i) == 1
            % log-transformation
            
        elseif model.transformX(i) == 2
            % logistic transformation
            Xsim(i,:) = 1./(1+exp(-Xsim(i,:)));
        elseif model.transformX(i) == 0
            % Level approximation
        end
    end
end

end

